package grape.house.rest.building.mapper;

import grape.house.rest.building.form.BuildingListForm;
import grape.house.rest.building.vo.BuildingPresalePermitVo;
import grape.house.service.building.po.Building;
import grape.common.rest.mvc.WebMapper;
import org.mapstruct.Mapper;
import grape.house.rest.building.form.BuildingCreateForm;
import grape.house.rest.building.form.BuildingUpdateForm;
import grape.house.rest.building.form.BuildingListPageForm;
import grape.house.rest.building.vo.BuildingVo;
import org.mapstruct.ReportingPolicy;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 楼栋表 前端领域模型映射
 * </p>
 *
 * @author yangwei
 * @since 2020-09-17
 */
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface BuildingWebMapper extends WebMapper<BuildingVo, Building> {

    Building formToPo(BuildingCreateForm f);
    Building formToPo(BuildingUpdateForm f);
    Building formToPo(BuildingListPageForm f);
    Building formToPo(BuildingListForm f);

    BuildingPresalePermitVo poToBuildingPresalePermitVo(Building building);
    default List<BuildingPresalePermitVo> posToBuildingPresalePermitVos(List<Building> buildings) {
        return buildings.stream().map(po->(poToBuildingPresalePermitVo(po))).collect(Collectors.toList());
    }
}
